#include "printer.h"
#include "serial.h"
#include "Timer.h"
#define PRINT 0xB8
#define POSITION 0xB9
#define CLEAR 0xB7


void locate(uint8_t x, uint8_t y)
{
    write_serial_3pi(POSITION, 1);
    write_serial_3pi(x, 1);
    write_serial_3pi(y, 1);
    int i;
    dumbAssTimer(1);
}

void printChar(char a)
{
    
    //locate(0x00,0x01);
    uint8_t command[4];
    command[1] = PRINT;
    command[2] = 0x01;
    command[3] = a;
    write_serial_3pi(command, 4);
    dumbAssTimer(1);
    

    
    
}

void printString(char* text, uint8_t length)
{
    int i;
    for(i=0; i<length; ++i)
    printChar(text[i]);     
}

void clearDisplay()
{
    uint8_t command[1];
    command[0] = CLEAR;
    write_serial_3pi(command, 1);
    dumbAssTimer(10000);
}
